<?php

/**
 * Created by Sublime.
 * User: yinni
 * Date: 2017/12/02 09:31
 */
namespace App\Http\Controllers\Admin\Evaluate;

use Log;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Services\Admin\EvaluateService;
use App\Http\Requests\Admin\UserRequest;
use \App\Http\Controllers\Admin\BaseController;

/**
 * 评测指标设置 河道检测点指标 河长考核指标
 * Class AlarmsettingController
 * @package App\Http\Controllers\Admin\Evaluate
 */
class EvaluateController extends BaseController
{
    protected $service;

    public function __construct(EvaluateService $service)
    {
        parent::__construct();
        $this->service = $service;
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $result = $this->service->index();
        return request()->ajax() ? $result : view('themes.admin.evaluate.index')->with($result);
    }

    public function alltimeinfo() {
        $alltime_data = $this->service->ajaxData();
        // $json_alltime_data = responce()->json($alltime_data);
        // dump($alltime_data);die;
        // Log::info('错误提示信息');
        // die();
        return $alltime_data;
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $monitor_id
     * @return \Illuminate\Http\Response
     */
    public function edit($monitor_id)
    {
        // dump($monitor_id);die;
        $result = $this->service->edit($monitor_id);
        return view('themes.admin.Evaluate.edit')->with($result);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        $route = $this->service->update($request->all(), $id);
        return redirect()->route($route);
    }


}